﻿using System;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;

namespace FlickrSL.Data
{
    public class EchoResponse : IXmlSerializable
    {
        private Dictionary<String, String> m_Members = new Dictionary<string, string>();

        public Dictionary<String, String> Members
        {
            get { return this.m_Members; }
        }

        public XmlSchema GetSchema()
        {
            return null;
        }

        public void ReadXml(XmlReader reader)
        {
            while (reader.IsStartElement())
            {
                String name = reader.Name;
                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement();
                    this.m_Members.Add(name, reader.ReadContentAsString());
                    reader.ReadEndElement();
                }
                else
                {
                    reader.Skip();
                    this.m_Members.Add(name, null);
                }
            }
        }

        public void WriteXml(XmlWriter writer)
        {
            foreach (KeyValuePair<String, String> pair in this.m_Members)
            {
                writer.WriteElementString(pair.Key, pair.Value);
            }
        }
    }
}
